/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using System.Collections.Generic;
using NetProtocol.POD;
using NetProtocol.Enum;
using IQIGame.Onigao.Game;
using IQIGame.Onigao.GamePlay;
using IQIGame.Onigao.Framework;
using Cysharp.Threading.Tasks;
using System;
using static IQIGame.Onigao.Game.MessageWrapper;

namespace NetProtocol.Client {
	/// <summary>
	/// 道具模块
	/// module : item
	/// </summary>
	public interface CNetItem : INetClientModule {
		
		public ISession GetSession();
	
		Dictionary<int, INetClientModule.Package2MessageWrapper> INetClientModule.GetModuleFunction()
        {
            MessageFunction sellItemResult_Delegate = (session, wrapper) =>
            {
            	var _wrapper = (MessageWrapper<SellItemResultData>)wrapper;
                SC_sellItemResult(session, ref _wrapper.message);
                MessageWrapperPool<SellItemResultData>.Put(_wrapper);
            };
            MessageFunction useItemResult_Delegate = (session, wrapper) =>
            {
            	var _wrapper = (MessageWrapper<UseItemResultData>)wrapper;
                SC_useItemResult(session, ref _wrapper.message);
                MessageWrapperPool<UseItemResultData>.Put(_wrapper);
            };
            MessageFunction exchangeResult_Delegate = (session, wrapper) =>
            {
            	var _wrapper = (MessageWrapper<ExchangeResultData>)wrapper;
                SC_exchangeResult(session, ref _wrapper.message);
                MessageWrapperPool<ExchangeResultData>.Put(_wrapper);
            };
            MessageFunction exchangeBatchResult_Delegate = (session, wrapper) =>
            {
            	var _wrapper = (MessageWrapper<ExchangeBatchResultData>)wrapper;
                SC_exchangeBatchResult(session, ref _wrapper.message);
                MessageWrapperPool<ExchangeBatchResultData>.Put(_wrapper);
            };
            MessageFunction setPortableItemResult_Delegate = (session, wrapper) =>
            {
            	var _wrapper = (MessageWrapper<SetPortableItemResultData>)wrapper;
                SC_setPortableItemResult(session, ref _wrapper.message);
                MessageWrapperPool<SetPortableItemResultData>.Put(_wrapper);
            };
            MessageFunction notifyItemChange_Delegate = (session, wrapper) =>
            {
            var _wrapper = (MessageWrapper<NotifyItemChangeData>)wrapper; 
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.item_notifyItemChange, "Recv->" + _wrapper.message.ToString());
#endif
                SC_notifyItemChange(session, _wrapper.message.updateList);
                MessageWrapperPool<NotifyItemChangeData>.Put(_wrapper);
            };
            MessageFunction notifyItemRemove_Delegate = (session, wrapper) =>
            {
            var _wrapper = (MessageWrapper<NotifyItemRemoveData>)wrapper; 
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.item_notifyItemRemove, "Recv->" + _wrapper.message.ToString());
#endif
                SC_notifyItemRemove(session, _wrapper.message.removeList);
                MessageWrapperPool<NotifyItemRemoveData>.Put(_wrapper);
            };
            MessageFunction notifyBasicItemChange_Delegate = (session, wrapper) =>
            {
            var _wrapper = (MessageWrapper<NotifyBasicItemChangeData>)wrapper; 
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.item_notifyBasicItemChange, "Recv->" + _wrapper.message.ToString());
#endif
                SC_notifyBasicItemChange(session, _wrapper.message.updateList);
                MessageWrapperPool<NotifyBasicItemChangeData>.Put(_wrapper);
            };
            MessageFunction notifyItemDebts_Delegate = (session, wrapper) =>
            {
            var _wrapper = (MessageWrapper<NotifyItemDebtsData>)wrapper; 
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.item_notifyItemDebts, "Recv->" + _wrapper.message.ToString());
#endif
                SC_notifyItemDebts(session, _wrapper.message.itemDebts);
                MessageWrapperPool<NotifyItemDebtsData>.Put(_wrapper);
            };
            MessageFunction notifyItemCdInfo_Delegate = (session, wrapper) =>
            {
            var _wrapper = (MessageWrapper<NotifyItemCdInfoData>)wrapper; 
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.item_notifyItemCdInfo, "Recv->" + _wrapper.message.ToString());
#endif
                SC_notifyItemCdInfo(session, _wrapper.message.itemCdInfo);
                MessageWrapperPool<NotifyItemCdInfoData>.Put(_wrapper);
            };
            MessageFunction notifyUpdatePortableItem_Delegate = (session, wrapper) =>
            {
            var _wrapper = (MessageWrapper<NotifyUpdatePortableItemData>)wrapper; 
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.item_notifyUpdatePortableItem, "Recv->" + _wrapper.message.ToString());
#endif
                SC_notifyUpdatePortableItem(session, _wrapper.message.itemId);
                MessageWrapperPool<NotifyUpdatePortableItemData>.Put(_wrapper);
            };
        
            Dictionary<int, INetClientModule.Package2MessageWrapper> retDic = new()
            {
                {NetMessageId.item_sellItemResult, (session, package) => {
                	var result = MessageWrapperPool<SellItemResultData>.Get();
                	result.Init(session, sellItemResult_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.item_useItemResult, (session, package) => {
                	var result = MessageWrapperPool<UseItemResultData>.Get();
                	result.Init(session, useItemResult_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.item_exchangeResult, (session, package) => {
                	var result = MessageWrapperPool<ExchangeResultData>.Get();
                	result.Init(session, exchangeResult_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.item_exchangeBatchResult, (session, package) => {
                	var result = MessageWrapperPool<ExchangeBatchResultData>.Get();
                	result.Init(session, exchangeBatchResult_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.item_setPortableItemResult, (session, package) => {
                	var result = MessageWrapperPool<SetPortableItemResultData>.Get();
                	result.Init(session, setPortableItemResult_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.item_notifyItemChange, (session, package) => {
                	var result = MessageWrapperPool<NotifyItemChangeData>.Get();
                	result.Init(session, notifyItemChange_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.item_notifyItemRemove, (session, package) => {
                	var result = MessageWrapperPool<NotifyItemRemoveData>.Get();
                	result.Init(session, notifyItemRemove_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.item_notifyBasicItemChange, (session, package) => {
                	var result = MessageWrapperPool<NotifyBasicItemChangeData>.Get();
                	result.Init(session, notifyBasicItemChange_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.item_notifyItemDebts, (session, package) => {
                	var result = MessageWrapperPool<NotifyItemDebtsData>.Get();
                	result.Init(session, notifyItemDebts_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.item_notifyItemCdInfo, (session, package) => {
                	var result = MessageWrapperPool<NotifyItemCdInfoData>.Get();
                	result.Init(session, notifyItemCdInfo_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.item_notifyUpdatePortableItem, (session, package) => {
                	var result = MessageWrapperPool<NotifyUpdatePortableItemData>.Get();
                	result.Init(session, notifyUpdatePortableItem_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
            };
            return retDic;
        }
#region Client-side Interface
		/// <summary>
        /// 
        /// </summary>
		public void SC_sellItemResult(ISession session, ref SellItemResultData message) 
		{
            _SC_sellItemResult(session, ref message);
		}
		
		public void _SC_sellItemResult(ISession session, ref SellItemResultData message)
		{
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.item_sellItemResult, "Recv->" + message.ToString());
#endif
			NetProtocolHelper.endCallRequest?.Invoke(NetMessageId.item_sellItemResult, message.code);
			MsgAsyncAwaiter<SellItemResultData>.Instance.CompleteMsgAwait(ref message);
		}
		
		/// <summary>
        /// addItems=获得的道具
        /// </summary>
		public void SC_useItemResult(ISession session, ref UseItemResultData message) 
		{
            _SC_useItemResult(session, ref message);
		}
		
		public void _SC_useItemResult(ISession session, ref UseItemResultData message)
		{
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.item_useItemResult, "Recv->" + message.ToString());
#endif
			NetProtocolHelper.endCallRequest?.Invoke(NetMessageId.item_useItemResult, message.code);
			MsgAsyncAwaiter<UseItemResultData>.Instance.CompleteMsgAwait(ref message);
		}
		
		/// <summary>
        /// success=是否成功，showItems=展示物品, exchangeRecords=兑换记录,key=cid，value=次数, 暴击倍数
        /// </summary>
		public void SC_exchangeResult(ISession session, ref ExchangeResultData message) 
		{
            _SC_exchangeResult(session, ref message);
		}
		
		public void _SC_exchangeResult(ISession session, ref ExchangeResultData message)
		{
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.item_exchangeResult, "Recv->" + message.ToString());
#endif
			NetProtocolHelper.endCallRequest?.Invoke(NetMessageId.item_exchangeResult, message.code);
			MsgAsyncAwaiter<ExchangeResultData>.Instance.CompleteMsgAwait(ref message);
		}
		
		/// <summary>
        /// showItems=展示物品, exchangeRecords=兑换记录,key=cid，value=次数
        /// </summary>
		public void SC_exchangeBatchResult(ISession session, ref ExchangeBatchResultData message) 
		{
            _SC_exchangeBatchResult(session, ref message);
		}
		
		public void _SC_exchangeBatchResult(ISession session, ref ExchangeBatchResultData message)
		{
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.item_exchangeBatchResult, "Recv->" + message.ToString());
#endif
			NetProtocolHelper.endCallRequest?.Invoke(NetMessageId.item_exchangeBatchResult, message.code);
			MsgAsyncAwaiter<ExchangeBatchResultData>.Instance.CompleteMsgAwait(ref message);
		}
		
		/// <summary>
        ///  提示用，不更新数据
        /// </summary>
		public void SC_setPortableItemResult(ISession session, ref SetPortableItemResultData message) 
		{
            _SC_setPortableItemResult(session, ref message);
		}
		
		public void _SC_setPortableItemResult(ISession session, ref SetPortableItemResultData message)
		{
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.item_setPortableItemResult, "Recv->" + message.ToString());
#endif
			NetProtocolHelper.endCallRequest?.Invoke(NetMessageId.item_setPortableItemResult, message.code);
			MsgAsyncAwaiter<SetPortableItemResultData>.Instance.CompleteMsgAwait(ref message);
		}
		
		/// <summary>
        ///  当客户端不知道明确操作目标的时候(道具)变动的数据通知
        /// </summary>
		protected void SC_notifyItemChange(ISession session, List<ItemPOD> updateList);
		/// <summary>
        ///  当客户端不知道明确操作目标的时候(道具)移除的数据通知
        /// </summary>
		protected void SC_notifyItemRemove(ISession session, List<long> removeList);
		/// <summary>
        ///  当客户端不知道明确操作目标的时候(道具)变动的数据通知 -- num为0不删除，货币默认0
        /// </summary>
		protected void SC_notifyBasicItemChange(ISession session, Dictionary<int, int> updateList);
		/// <summary>
        ///  更新玩家道具欠债，全量更新 -- num为0可删
        /// </summary>
		protected void SC_notifyItemDebts(ISession session, Dictionary<int, int> itemDebts);
		/// <summary>
        ///  同步物品冷却信息，全量更新
        /// </summary>
		protected void SC_notifyItemCdInfo(ISession session, Dictionary<int, int> itemCdInfo);
		/// <summary>
        ///  通知更新快捷道具
        /// </summary>
		protected void SC_notifyUpdatePortableItem(ISession session, long itemId);
#endregion
#region Server-side Interface
		/// <summary>
        ///  出售道具
        /// </summary>
    	public UniTask<SellItemResultData> CS_sellItem(List<long> itemIds, Dictionary<int, int> basicItems)
        {
            return _CS_sellItem(itemIds, basicItems);
        }
        
        public UniTask<SellItemResultData> _CS_sellItem(List<long> itemIds, Dictionary<int, int> basicItems)
        {
        	ISession session = GetSession();
        	if(session == null) return UniTask.FromResult(default(SellItemResultData));
#if ENABLE_NET_LOG || UNITY_EDITOR
			NetProtocolHelper.ClientLog(NetMessageId.item_sellItem, "Send->"+"Item.CS_sellItem { "
				+ "itemIds="
				+ itemIds.ToString<long>()
				+ ", basicItems="
				+ basicItems.ToString<int, int>()
				+" }");
#endif
        	UniTask<SellItemResultData> task = MsgAsyncAwaiter<SellItemResultData>.Instance.AddMsgAwait();
        	session.SendPack(Pack_for_sellItem(itemIds, basicItems));
        	NetProtocolHelper.beginCallRequest?.Invoke(NetMessageId.item_sellItemResult);
			return task;
        }
		
		public static SendPackage Pack_for_sellItem(List<long> itemIds, Dictionary<int, int> basicItems) 
		{
			SendPackage si_p = NetProtocolHelper.GetSendPackage();
			si_p.Header.Messagid = NetMessageId.item_sellItem;
			si_p.StartWrite();
			SOutputStream _out = si_p.OutputStream;
			_out.Write_list_long(itemIds);	
			_out.Write_map_int_int(basicItems);
			return si_p;
		}
		/// <summary>
        ///  使用道具
        /// </summary>
    	public UniTask<UseItemResultData> CS_useItem(UseItemRequestPOD request)
        {
            return _CS_useItem(request);
        }
        
        public UniTask<UseItemResultData> _CS_useItem(UseItemRequestPOD request)
        {
        	ISession session = GetSession();
        	if(session == null) return UniTask.FromResult(default(UseItemResultData));
#if ENABLE_NET_LOG || UNITY_EDITOR
			NetProtocolHelper.ClientLog(NetMessageId.item_useItem, "Send->"+"Item.CS_useItem { "
				+ "request="
				+ request
				+" }");
#endif
        	UniTask<UseItemResultData> task = MsgAsyncAwaiter<UseItemResultData>.Instance.AddMsgAwait();
        	session.SendPack(Pack_for_useItem(request));
        	NetProtocolHelper.beginCallRequest?.Invoke(NetMessageId.item_useItemResult);
			return task;
        }
		
		public static SendPackage Pack_for_useItem(UseItemRequestPOD request) 
		{
			SendPackage si_p = NetProtocolHelper.GetSendPackage();
			si_p.Header.Messagid = NetMessageId.item_useItem;
			si_p.StartWrite();
			SOutputStream _out = si_p.OutputStream;
			_out.Write_pod(request);
			return si_p;
		}
		/// <summary>
        ///  兑换
        /// </summary>
    	public UniTask<ExchangeResultData> CS_exchange(int cid, int count)
        {
            return _CS_exchange(cid, count);
        }
        
        public UniTask<ExchangeResultData> _CS_exchange(int cid, int count)
        {
        	ISession session = GetSession();
        	if(session == null) return UniTask.FromResult(default(ExchangeResultData));
#if ENABLE_NET_LOG || UNITY_EDITOR
			NetProtocolHelper.ClientLog(NetMessageId.item_exchange, "Send->"+"Item.CS_exchange { "
				+ "cid="
				+ cid
				+ ", count="
				+ count
				+" }");
#endif
        	UniTask<ExchangeResultData> task = MsgAsyncAwaiter<ExchangeResultData>.Instance.AddMsgAwait();
        	session.SendPack(Pack_for_exchange(cid, count));
        	NetProtocolHelper.beginCallRequest?.Invoke(NetMessageId.item_exchangeResult);
			return task;
        }
		
		public static SendPackage Pack_for_exchange(int cid, int count) 
		{
			SendPackage si_p = NetProtocolHelper.GetSendPackage();
			si_p.Header.Messagid = NetMessageId.item_exchange;
			si_p.StartWrite();
			SOutputStream _out = si_p.OutputStream;
			_out.Write_int(cid);
			_out.Write_int(count);
			return si_p;
		}
		/// <summary>
        ///  批量兑换idCounts(key=cid,value=count)
        /// </summary>
    	public UniTask<ExchangeBatchResultData> CS_exchangeBatch(Dictionary<int, int> idCounts)
        {
            return _CS_exchangeBatch(idCounts);
        }
        
        public UniTask<ExchangeBatchResultData> _CS_exchangeBatch(Dictionary<int, int> idCounts)
        {
        	ISession session = GetSession();
        	if(session == null) return UniTask.FromResult(default(ExchangeBatchResultData));
#if ENABLE_NET_LOG || UNITY_EDITOR
			NetProtocolHelper.ClientLog(NetMessageId.item_exchangeBatch, "Send->"+"Item.CS_exchangeBatch { "
				+ "idCounts="
				+ idCounts.ToString<int, int>()
				+" }");
#endif
        	UniTask<ExchangeBatchResultData> task = MsgAsyncAwaiter<ExchangeBatchResultData>.Instance.AddMsgAwait();
        	session.SendPack(Pack_for_exchangeBatch(idCounts));
        	NetProtocolHelper.beginCallRequest?.Invoke(NetMessageId.item_exchangeBatchResult);
			return task;
        }
		
		public static SendPackage Pack_for_exchangeBatch(Dictionary<int, int> idCounts) 
		{
			SendPackage si_p = NetProtocolHelper.GetSendPackage();
			si_p.Header.Messagid = NetMessageId.item_exchangeBatch;
			si_p.StartWrite();
			SOutputStream _out = si_p.OutputStream;
			_out.Write_map_int_int(idCounts);
			return si_p;
		}
		/// <summary>
        ///  设置快捷道具，0表示卸下，int值表示cid，long值表示唯一id
        /// </summary>
    	public UniTask<SetPortableItemResultData> CS_setPortableItem(long itemId)
        {
            return _CS_setPortableItem(itemId);
        }
        
        public UniTask<SetPortableItemResultData> _CS_setPortableItem(long itemId)
        {
        	ISession session = GetSession();
        	if(session == null) return UniTask.FromResult(default(SetPortableItemResultData));
#if ENABLE_NET_LOG || UNITY_EDITOR
			NetProtocolHelper.ClientLog(NetMessageId.item_setPortableItem, "Send->"+"Item.CS_setPortableItem { "
				+ "itemId="
				+ itemId
				+" }");
#endif
        	UniTask<SetPortableItemResultData> task = MsgAsyncAwaiter<SetPortableItemResultData>.Instance.AddMsgAwait();
        	session.SendPack(Pack_for_setPortableItem(itemId));
        	NetProtocolHelper.beginCallRequest?.Invoke(NetMessageId.item_setPortableItemResult);
			return task;
        }
		
		public static SendPackage Pack_for_setPortableItem(long itemId) 
		{
			SendPackage si_p = NetProtocolHelper.GetSendPackage();
			si_p.Header.Messagid = NetMessageId.item_setPortableItem;
			si_p.StartWrite();
			SOutputStream _out = si_p.OutputStream;
			_out.Write_long(itemId);
			return si_p;
		}
#endregion
#region Messages
        public struct SellItemResultData : IReceiveMessage {
        	private int? _code;
        	public int code {get{return _code == null ? -1 : (int)_code;}private set{_code = value;}}
            public bool IsFail => _code != null && _code != 0;
            public bool IsSuccess =>_code != null && _code == 0;
            public bool IsCanceled => _code == null;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                code = _in.HasRemaining() ? _in.Read_int() : default;
            }
            
            public int GetMessageId() {return NetMessageId.item_sellItemResult;}
            
            public override string ToString()
            {
                return "Item.sellItemResult"+ ", code="+ code;
            }
        }
        public struct UseItemResultData : IReceiveMessage {
        	private int? _code;
        	public int code {get{return _code == null ? -1 : (int)_code;}private set{_code = value;}}
	        public UseItemResultPOD result;
            public bool IsFail => _code != null && _code != 0;
            public bool IsSuccess =>_code != null && _code == 0;
            public bool IsCanceled => _code == null;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                code = _in.HasRemaining() ? _in.Read_int() : default;
                result = _in.HasRemaining() ? _in.Read_pod<UseItemResultPOD>(UseItemResultPOD.DynamicFactory) : default;
            }
            
            public int GetMessageId() {return NetMessageId.item_useItemResult;}
            
            public override string ToString()
            {
                return "Item.useItemResult"+ ", code="+ code+ ", result="+ result;
            }
        }
        public struct ExchangeResultData : IReceiveMessage {
        	private int? _code;
        	public int code {get{return _code == null ? -1 : (int)_code;}private set{_code = value;}}
	        public bool success;
	        public List<ItemShowPOD> showItems;
	        public Dictionary<int, int> exchangeRecords;
	        public float critMultiple;
            public bool IsFail => _code != null && _code != 0;
            public bool IsSuccess =>_code != null && _code == 0;
            public bool IsCanceled => _code == null;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                code = _in.HasRemaining() ? _in.Read_int() : default;
                success = _in.HasRemaining() ? _in.Read_boolean() : default;
                showItems = _in.HasRemaining() ? _in.Read_list_pod<ItemShowPOD>(ItemShowPOD.DynamicFactory) : default;
                exchangeRecords = _in.HasRemaining() ? _in.Read_map_int_int() : default;
                critMultiple = _in.HasRemaining() ? _in.Read_float() : default;
            }
            
            public int GetMessageId() {return NetMessageId.item_exchangeResult;}
            
            public override string ToString()
            {
                return "Item.exchangeResult"+ ", code="+ code+ ", success="+ success+ ", showItems="+ showItems.ToString<ItemShowPOD>()+ ", exchangeRecords="+ exchangeRecords.ToString<int, int>()+ ", critMultiple="+ critMultiple;
            }
        }
        public struct ExchangeBatchResultData : IReceiveMessage {
        	private int? _code;
        	public int code {get{return _code == null ? -1 : (int)_code;}private set{_code = value;}}
	        public Dictionary<int, int> successInfo;
	        public List<ItemShowPOD> showItems;
	        public Dictionary<int, int> exchangeRecords;
            public bool IsFail => _code != null && _code != 0;
            public bool IsSuccess =>_code != null && _code == 0;
            public bool IsCanceled => _code == null;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                code = _in.HasRemaining() ? _in.Read_int() : default;
                successInfo = _in.HasRemaining() ? _in.Read_map_int_int() : default;
                showItems = _in.HasRemaining() ? _in.Read_list_pod<ItemShowPOD>(ItemShowPOD.DynamicFactory) : default;
                exchangeRecords = _in.HasRemaining() ? _in.Read_map_int_int() : default;
            }
            
            public int GetMessageId() {return NetMessageId.item_exchangeBatchResult;}
            
            public override string ToString()
            {
                return "Item.exchangeBatchResult"+ ", code="+ code+ ", successInfo="+ successInfo.ToString<int, int>()+ ", showItems="+ showItems.ToString<ItemShowPOD>()+ ", exchangeRecords="+ exchangeRecords.ToString<int, int>();
            }
        }
        public struct SetPortableItemResultData : IReceiveMessage {
        	private int? _code;
        	public int code {get{return _code == null ? -1 : (int)_code;}private set{_code = value;}}
            public bool IsFail => _code != null && _code != 0;
            public bool IsSuccess =>_code != null && _code == 0;
            public bool IsCanceled => _code == null;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                code = _in.HasRemaining() ? _in.Read_int() : default;
            }
            
            public int GetMessageId() {return NetMessageId.item_setPortableItemResult;}
            
            public override string ToString()
            {
                return "Item.setPortableItemResult"+ ", code="+ code;
            }
        }
        public struct NotifyItemChangeData : IReceiveMessage {
	        public List<ItemPOD> updateList;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                updateList = _in.HasRemaining() ? _in.Read_list_pod<ItemPOD>(ItemPOD.DynamicFactory) : default;
            }
            
            public int GetMessageId() {return NetMessageId.item_notifyItemChange;}
            
            public override string ToString()
            {
                return "Item.notifyItemChange"+ ", updateList="+ updateList.ToString<ItemPOD>();
            }
        }
        public struct NotifyItemRemoveData : IReceiveMessage {
	        public List<long> removeList;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                removeList = _in.HasRemaining() ? _in.Read_list_long() : default;
            }
            
            public int GetMessageId() {return NetMessageId.item_notifyItemRemove;}
            
            public override string ToString()
            {
                return "Item.notifyItemRemove"+ ", removeList="+ removeList.ToString<long>();
            }
        }
        public struct NotifyBasicItemChangeData : IReceiveMessage {
	        public Dictionary<int, int> updateList;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                updateList = _in.HasRemaining() ? _in.Read_map_int_int() : default;
            }
            
            public int GetMessageId() {return NetMessageId.item_notifyBasicItemChange;}
            
            public override string ToString()
            {
                return "Item.notifyBasicItemChange"+ ", updateList="+ updateList.ToString<int, int>();
            }
        }
        public struct NotifyItemDebtsData : IReceiveMessage {
	        public Dictionary<int, int> itemDebts;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                itemDebts = _in.HasRemaining() ? _in.Read_map_int_int() : default;
            }
            
            public int GetMessageId() {return NetMessageId.item_notifyItemDebts;}
            
            public override string ToString()
            {
                return "Item.notifyItemDebts"+ ", itemDebts="+ itemDebts.ToString<int, int>();
            }
        }
        public struct NotifyItemCdInfoData : IReceiveMessage {
	        public Dictionary<int, int> itemCdInfo;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                itemCdInfo = _in.HasRemaining() ? _in.Read_map_int_int() : default;
            }
            
            public int GetMessageId() {return NetMessageId.item_notifyItemCdInfo;}
            
            public override string ToString()
            {
                return "Item.notifyItemCdInfo"+ ", itemCdInfo="+ itemCdInfo.ToString<int, int>();
            }
        }
        public struct NotifyUpdatePortableItemData : IReceiveMessage {
	        public long itemId;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                itemId = _in.HasRemaining() ? _in.Read_long() : default;
            }
            
            public int GetMessageId() {return NetMessageId.item_notifyUpdatePortableItem;}
            
            public override string ToString()
            {
                return "Item.notifyUpdatePortableItem"+ ", itemId="+ itemId;
            }
        }
    }
#endregion
}